
/**
说明：
1、进入播放列表页面执行<body onload="JsHandler()">方法，把视频列表和当前位置传给android
2、焦点在mini视频div上，点击下，可以调用js中方法play()，可以实现原生android视频。播放/暂停/重新播放等功能
3、焦点在全屏播放按钮div上，点击下，可以调用js中方法fullPlay()，可以实现原生android视频。全屏播放
*/

    var default_data = {
        error: "1"
    };

    var connectMerchantJSBridge = function (callback) {
        try {
            if (window.TestJavascriptBridge) {
                callback(TestJavascriptBridge);
            } else {
                document.addEventListener("TestJavascriptBridgeReady", function () {
                    callback(TestJavascriptBridge);
                }, false);
            }
        } catch (ex) { }
    };

    var cmbMerchantBridge = {
        initSignNet: function (payData,name) {
            if (!payData) {
                payData = default_data;
            }
            connectMerchantJSBridge(function (bridge) {
                if (typeof bridge === "undefined") {
                    return;
                }
                bridge.callHandler(name, JSON.stringify(payData));
            });
        },
    };

    /*app native调用本页面方法*/
    connectMerchantJSBridge(function(bridge) {
        bridge.init(function(message, responseCallback) {

        });

        bridge.registerHandler("click1", function(data, responseCallback) {
            responseCallback("receive click1");
            /*弹窗*/
            dialog();
        });

        bridge.registerHandler("click2", function(data, responseCallback) {
            responseCallback("receive click2");
        });

         bridge.registerHandler("click3", function(data, responseCallback) {
            responseCallback("receive click3");
        });
    })

    window.cmbMerchantBridge = cmbMerchantBridge;

    function click2(){
        var objData = new datas();
        var shareData = objData.click2;

        try {
            cmbMerchantBridge.initSignNet(shareData, "initSignNetShare");
        } catch (ex) { }
    }

    function play(){
    <!--alert("播放/暂停/重新播放");-->
        var objData = new datas();
        var payData = objData.click1;
            try {
                cmbMerchantBridge.initSignNet(payData, "play");
            } catch (ex) { }
    }

    function fullPlay(){
        <!--alert("全屏播放");-->

            var objData = new datas();
            var payData = objData.click1;
                try {
                    cmbMerchantBridge.initSignNet(payData, "fullPlay");
                } catch (ex) { }
    }

    <!-- 这个是本地测试方法，实际使用使用以上两个方法 -->
    function JsHandler(){
     var objData = new datas();
        var handlerData = objData.handlerData;
        cmbMerchantBridge.initSignNet(handlerData, "jsHandler1");

        cmbMerchantBridge.initSignNet(handlerData, "jsHandler2");
    }


    function datas()
    {
        this.click1 = {
            title: "hello title",
            play_pos:0,
            play_list:[{"play_url":"http://s.61baobao.com/mobile/res/01_syz.mp4"},{"play_url":"http://s.61baobao.com/mobile/res/09_szg.mp4"}],
        };

        this.click2 = {
            subject : "this is title",
        };

        this.handlerData = {
            status : "ok",
            title: "hello title",
            play_pos:0,
            play_list:[{"play_url":"http://s.61baobao.com/mobile/res/01_syz.mp4"},{"play_url":"http://s.61baobao.com/mobile/res/09_szg.mp4"}],
        }
    }
